import requert from "@/utils/request";
// import store from "@/store";

export const login = (data) => {
  return requert({
    method: "POST",
    url: "/v1_0/authorizations",
    data,
  });
};

export const sendSms = (mobile) => {
  return requert({
    method: "GET",
    url: `/v1_0/authorizations/${mobile}`,
  });
};

export const getUserInfo = () => {
  return requert({
    method: "GET",
    url: `/v1_0/user`,
    // headers: {
    //   Authorization: `Bearer ${store.state.user.token}`,
    // },
  });
};

// 获取用户频道列表
export const getUserChannerls = () => {
  return requert({
    method: "GET",
    url: `/v1_0/user/channels`,
  });
};

export const addFollw = (target) => {
  return requert({
    method: "POST",
    url: "/v1_0/user/followings",
    data: {
      target,
    },
  });
};

export const deleteFollow = (target) => {
  return requert({
    method: "DELETE",
    url: `/v1_0/user/followings/${target}`,
  });
};

// 获取用户资料
export const getUserProfile = () => {
  return requert({
    method: "GET",
    url: "/v1_0/user/profile",
  });
};

// 更新用户昵称
export const updateUserProfile = (data) => {
  return requert({
    method: "PATCH",
    url: "/v1_0/user/profile",
    data,
  });
};

// 更新用户头像
export const updateUserPhoto = (data) => {
  return requert({
    method: "PATCH",
    url: "/v1_0/user/photo",
    data,
  });
};
